package com.hzlh.common.util;




public class SYSID {/*
	public static String getPrimaryKey(){
	
			
			StringBuffer sb=new StringBuffer();
			SimpleDateFormat sf=new SimpleDateFormat("yyyyMMddHHmmss");
			sb.append(sf.format(new Date()));
			Random rand=new Random(System.currentTimeMillis());
			String num=rand.nextInt(10000)+"";
		    switch(num.length())
		    {
		      case 1:sb.append("000"+num);break;
		      case 2:sb.append("00"+num);break;
		      case 3:sb.append("0"+num);break;
		      case 4:sb.append(num);break;
		      default:sb.append("0000");
		    }
			try
			{
				Thread.sleep(10);
		   
		}catch(Exception e)
		 {
			 e.printStackTrace();
		 }
		 return sb.toString();
	}
*/	
	@SuppressWarnings("rawtypes")
	public static Boolean getkey()
	{
		return true;
	}	
	/*HttpURLConnection conn = null; 
	//String uriAPI = "http://115.236.176.154:1756/MassageAuditService.svc/inc/exa/M/"; 
	String uriAPI = " http://app.jxt360.com/mcpp/index.php?mod=Index&act=getSrvControlInfo&pv=4|2cb962ac59075b964b07152d" ;
	String RT = "";
	try {
	URL url=new URL(uriAPI);
	conn=(HttpURLConnection)url.openConnection();
	conn.setDoOutput(true);    
	            conn.setRequestMethod("GET");    
	            conn.setUseCaches(false); 
	            conn.setRequestProperty("Content-Type", "application/json");  
	            conn.setRequestProperty("accept", "application/json");   
	            conn.connect();   
	            BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream(),"UTF-8")); 
	            String line = "";
	            while ((line = in.readLine()) != null) { 
	            	RT+=line;
	            	//System.out.println(line);
	            }   
	} catch (MalformedURLException e) {
	// TODO Auto-generated catch block
	e.printStackTrace();
	} catch (IOException e) {
	// TODO Auto-generated catch block
	e.printStackTrace();
	}finally{
	if(conn != null)
	conn.disconnect();
	}
	//System.out.println(RT);

	//JSONObject rt=mapper.convertValue(RT, JSONObject.class);
	String ret = null;
	try {
	//ret = al.getString("ret");
		HashMap al=(HashMap)JSON.Decode(RT);
		//HashMap m=(HashMap)al.get(0);
		//ObjectMapper mapper = new ObjectMapper();
		//System.out.println(m.get("ret"));
		ret=(String) al.get("ret");

	} catch (Exception e) {
	// TODO Auto-generated catch block
	e.printStackTrace();
	}
	Boolean bool=false;
	if(ret.equals("1"))
	{
	bool=true;
	}else{
	bool=false;
	}
	return bool;
	}	*/
	/*public static void main(String[] args) {
		System.out.println(getkey());
	}*/


	
	public final static String BASE_SPLIT = ";";
	public final static String DBKEY_SPLIT = ".";

	public static void main(String[] args) {  
		try {
			System.out.println("1.1".replaceFirst(DBKEY_SPLIT, BASE_SPLIT).split(BASE_SPLIT).length);
			//ArrayDeque  ad = new ArrayDeque();
          for (int i = 0; i < 100000; i++)
          {
        	  String k= getPrimaryKey();
        	  //if(ad.contains(k))
        		  System.out.println(k);
        	 // else
        	//	  ad.add(k);
          }
      } catch (Exception e) {
          e.printStackTrace();
      }
	}
	
	private static long systemTimeMillis =0l;
	private static long synchronizedNum =0l;
	private static StringBuilder primaryUniqueKey;
	
	/**
	 * 还原db数据信息
	 * @param dbKey
	 * @return #1 数据产生时间起点，#2数据产生序列号
	 */
	/*public static String[] splitDbkey(String dbKey){
		return dbKey.replaceFirst(DBKEY_SPLIT, BASE_SPLIT).split(BASE_SPLIT);
	}*/
	
	/**
	 * 获得一个数据记录的主键Key
	 * @return 全局唯一主键
	 */
	public synchronized static String getPrimaryKey(){
		primaryUniqueKey = new StringBuilder(25);
		long currentTimeMillis = System.currentTimeMillis();
		//同步判定
		if(currentTimeMillis>systemTimeMillis){
			synchronizedNum = 0l;
			systemTimeMillis = currentTimeMillis;
		}else{
			synchronizedNum++;
		}
		primaryUniqueKey.append(systemTimeMillis).append(synchronizedNum);
		return primaryUniqueKey.toString();
	}
	}
